package com.iplay.thezen.flyweight;

import java.util.HashMap;

/**
 * @author dangwu
 * @since 2021/9/27 3:59 下午
 */
public class FlyweightFactory {
    private static HashMap<String,Flyweight> pool = new HashMap<>();
    public static Flyweight getFlyweight(String extrinsic){
        Flyweight flyweight = null;
        if (pool.containsKey(extrinsic)){
            flyweight = pool.get(extrinsic);
        }else {
            flyweight = new ConcreteFlyweight1(extrinsic);
            pool.put(extrinsic,flyweight);
        }
        return flyweight;
    }
}
